package com.ews.onlineexchange.controller;

import java.util.ArrayList;
import java.util.List;

import javax.enterprise.inject.Model;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import com.ews.onlineexchange.model.DataEntity;
import com.ews.onlineexchange.model.ServiceBuyer;
import com.ews.onlineexchange.model.ServiceSupplier;
import com.ews.onlineexchange.service.EntityQuery;

@Model
public class UnauditServiceBuyerList extends EntityQuery<ServiceBuyer> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public UnauditServiceBuyerList() {
		setOrder("auditted DESC");
		setMaxResults(MAX_RESULTS_NORMAL);
	}

	@Override
	protected List<Predicate> getRestrictions(CriteriaBuilder cb, Root<ServiceBuyer> entity) {
		List<Predicate> restrictions = new ArrayList<Predicate>();
		restrictions.add(cb.equal(entity.get("delFlag"), DataEntity.DEL_FLAG_NORMAL));
		restrictions.add(cb.isNull(entity.get("auditted")));
		return restrictions;
	}

	

	

}
